package net.minecraft.src;

import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

import net.minecraft.src.forge.*;
import karma.main.*;
import net.minecraft.client.Minecraft;


public class mod_KarmaCraft extends BaseMod
{
    EntityPlayer player;
    public static boolean holyWep;
    public static boolean hellWep;
    public static boolean load = false;
    public static EnumArmorMaterial EL;
    public static EnumArmorMaterial Holy;
    public static EnumArmorMaterial Hell;
    public static EnumToolMaterial HOLY;
    public static EnumToolMaterial HELL;
    public static EnumRarity ENCHANTED = EnumHelperClient.addRarity("enchanted", 6, "Enchanted");
    public static KeyBinding key = new KeyBinding("Karma Key", Keyboard.KEY_R);
    public static final Block Holystone;
    public static final Block Hellstone;
    public static final Block Netherstone;
    public static Block Enchanter;
    public static int holyBow = ModLoader.addOverride("/gui/items.png", "/karma/holybow.png");
    public static int holyBow2 = ModLoader.addOverride("/gui/items.png", "/karma/holybow2.png");
    public static int holyBow3 = ModLoader.addOverride("/gui/items.png", "/karma/holybow3.png");
    public static int holyBow4 = ModLoader.addOverride("/gui/items.png", "/karma/holybow4.png");
    public static int hellBow = ModLoader.addOverride("/gui/items.png", "/karma/hellbow.png");
    public static int hellBow2 = ModLoader.addOverride("/gui/items.png", "/karma/hellbow2.png");
    public static int hellBow3 = ModLoader.addOverride("/gui/items.png", "/karma/hellbow3.png");
    public static int hellBow4 = ModLoader.addOverride("/gui/items.png", "/karma/hellbow4.png");
    public static int EnchanterSide = ModLoader.addOverride("/terrain.png", "/karma/EnchanterSide.png");
    public static int EnchanterTop = ModLoader.addOverride("/terrain.png", "/karma/EnchanterTop.png");
    public static int EnchanterBottom = ModLoader.addOverride("/terrain.png", "/karma/EnchanterBottom.png");
    public static final Item MagicPowder = (new ItemKarmaCrafting(7000, false, false)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/magicpowder.png")).setItemName("magicpowder");
    public static final Item DiamondStick = (new ItemKarmaCrafting(7007, false, false)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/diamondstick.png")).setItemName("diamondstick");
    public static final Item EnchantLeather = (new ItemKarmaCrafting(7001, true, true)).setIconCoord(7, 6).setItemName("enchantleather");
    public static final Item BlankAmulet = (new ItemKarmaCrafting(7020, false, false)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/blankamulet.png")).setItemName("blankamulet");
    public static final Item ChargedAmulet = (new ItemKarmaCrafting(7021, false, true)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/blankamulet.png")).setItemName("chargedamulet");
    public static final Item ChargedDiamond = (new ItemKarmaCrafting(7022, false, true)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/chargediamond.png")).setItemName("chargeddiamond");
    public static final Item EnchantPaper = (new ItemKarmaCrafting(7031, true, true)).setIconCoord(10, 3).setItemName("enchantpaper");
    public static final Item StoneTablet = (new ItemStoneTablet(7033)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/stonetablet.png")).setItemName("stonetablet");
    public static final Item StoneHammer = new ItemKarmaCrafting(7034, false, false).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/stonehammer.png")).setItemName("stonehammer");
    public static final Item StoneChisel = new ItemKarmaCrafting(7035, false, false).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/stonechisel.png")).setItemName("stonechisel");
    public static final Item BookofLore = (new ItemBookOfLore(7032)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/booklore.png")).setItemName("bookoflore");
    public static final Item StoneHammerChisel = new ItemStoneHammerChisel(7036).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/stonehammerchisel.png")).setItemName("stonehammerandchisel");
    public static final Item HellPickaxe;
    public static final Item HellShovel;
    public static final Item HellAxe;
    public static final Item HellHoe;
    public static final Item HellSword;
    public static final Item HolyPickaxe;
    public static final Item HolyShovel;
    public static final Item HolyAxe;
    public static final Item HolyHoe;
    public static final Item HolySword;
    public static final Item HolyBow = (new ItemHolyBow(7017)).setItemName("holybow");
    public static final Item HellBow = (new ItemHellBow(7018)).setItemName("hellbow");
    public static final Item TeleAmulet = (new ItemTeleAmulet(7019)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/teleAmulet.png")).setItemName("TeleAmulet");
    public static final Item ELHelm;
    public static final Item ELBody;
    public static final Item ELLegs;
    public static final Item ELBoots;
    public static final Item HolyHelm;
    public static final Item HolyBody;
    public static final Item HolyLegs;
    public static final Item HolyBoots;
    public static final Item HellHelm;
    public static final Item HellBody;
    public static final Item HellLegs;
    public static final Item HellBoots;
    public static final Item AncientText = new ItemAncientText(7037).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/ancientscroll.png")).setItemName("ancientscroll");
    public GuiKarmaHUD guikarmahud;
    public ItemHellSword hellsword;
    
    public void load()
    {
        ItemELBoots.allowJump = true;
        ItemHellLegs.allowJump = true;
        ItemELBoots.allowNoFall = true;
        ItemELBody.ELBodyWorn = false;
        holyWep = false;
        hellWep = false;
        load = true;
        ModLoader.setInGameHook(this, true, false);
    }

    public boolean onTickInGame(float f, Minecraft minecraft)
    {
        World world = minecraft.theWorld;
        EntityPlayer entityplayer = minecraft.thePlayer;
        
        ItemELHelm.checkIfWorn(minecraft);
        ItemELBody.checkIfWorn(minecraft);
        ItemELLegs.checkIfWorn(minecraft);
        ItemELBoots.checkIfWorn(minecraft);
        
        ItemHellHelm.checkIfWorn(minecraft);
        ItemHellBody.checkIfWorn(minecraft);
        ItemHellLegs.checkIfWorn(minecraft);
        ItemHellBoots.checkIfWorn(minecraft);
        
        ItemHolyHelm.checkIfWorn(minecraft);
        ItemHolyBody.checkIfWorn(minecraft);
        ItemHolyLegs.checkIfWorn(minecraft);
        ItemHolyBoots.checkIfWorn(minecraft);
        
        ItemTeleAmulet.doStuff();
        this.drawHUDs(minecraft);
        return true;
    }
    
    private void drawHUDs(Minecraft mc) 
    {
    	if (mc.inGameHasFocus && mc.isGuiEnabled())
        {
        	if (ItemHolyLegs.worn)
        	{
        		guikarmahud.render("holylegs");
        	}
        	if (ItemHellBoots.worn)
        	{
        		guikarmahud.render("hellboots");
        	}
        }
	}

	public String getVersion()
    {
        return "v1.0 Alpha by UnixRano";
    }

    void registers()
    {
    	ModLoader.registerKey(this, key, true);
    	ModLoader.registerBlock(Holystone);
        ModLoader.registerBlock(Hellstone);
        ModLoader.registerBlock(Netherstone);
        ModLoader.registerBlock(Enchanter);
        ModLoader.registerTileEntity(karma.main.TileEntityEnchanter.class, "Enchanter");
    }
    
    void names()
    {
    	ModLoader.addName(Holystone, "Holystone");
        ModLoader.addName(Hellstone, "Hellstone");
        ModLoader.addName(Netherstone, "Netherstone");
        ModLoader.addName(Enchanter, "Enchanter");
        ModLoader.addName(MagicPowder, "Magic Powder");
        ModLoader.addName(DiamondStick, "Diamond Stick");
        ModLoader.addName(EnchantLeather, "Enchanted Leather");
        ModLoader.addName(HellPickaxe, "Hellstone Pickaxe");
        ModLoader.addName(HellShovel, "Hellstone Shovel");
        ModLoader.addName(HellAxe, "Hellstone Axe");
        ModLoader.addName(HellHoe, "Hellstone Hoe");
        ModLoader.addName(HellSword, "Hellstone Sword");
        ModLoader.addName(HolyPickaxe, "Holystone Pickaxe");
        ModLoader.addName(HolyShovel, "Holystone Shovel");
        ModLoader.addName(HolyAxe, "Holystone Axe");
        ModLoader.addName(HolyHoe, "Holystone Hoe");
        ModLoader.addName(HolySword, "Holystone Sword");
        ModLoader.addName(ELHelm, "Enchanted Leather Helmet");
        ModLoader.addName(ELBody, "Enchanted Leather Chestplate");
        ModLoader.addName(ELLegs, "Enchanted Leather Leggings");
        ModLoader.addName(ELBoots, "Enchanted Leather Boots");
        ModLoader.addName(HolyHelm, "Holystone Helmet");
        ModLoader.addName(HolyBody, "Holystone Chestplate");
        ModLoader.addName(HolyLegs, "Holystone Leggings");
        ModLoader.addName(HolyBoots, "Holystone Boots");
        ModLoader.addName(HellHelm, "Hellstone Helmet");
        ModLoader.addName(HellBody, "Hellstone Chestplate");
        ModLoader.addName(HellLegs, "Hellstone Leggings");
        ModLoader.addName(HellBoots, "Hellstone Boots");
        ModLoader.addName(HolyBow, "Holy Bow");
        ModLoader.addName(HellBow, "Hell Bow");
        ModLoader.addName(TeleAmulet, "Amulet of Teleportation");
        ModLoader.addName(BlankAmulet, "Blank Amulet");
        ModLoader.addName(ChargedAmulet, "Charged Amulet");
        ModLoader.addName(ChargedDiamond, "Charged Diamond");
        ModLoader.addName(EnchantPaper, "Enchanted Paper");
        ModLoader.addName(BookofLore, "Book of Lore");
        ModLoader.addName(StoneTablet, "Stone Tablet");
        ModLoader.addName(StoneHammer, "Hammer");
        ModLoader.addName(StoneChisel, "Chisel");
        ModLoader.addName(StoneHammerChisel, "Hammer and Chisel");
        
        ModLoader.addName(AncientText, "Ancient Scroll");
    }
    
    void crafting()
    {
         ModLoader.addRecipe(new ItemStack(Item.arrow, 16), new Object[]
                 {
         			"F", "S", "C", 'F', Item.flint, 'S', DiamondStick, 'C', Item.feather 
                 });
         ModLoader.addRecipe(new ItemStack(Enchanter, 1), new Object[]
                 {
                     " P ", "PDP", "OOO", 'P', MagicPowder, 'D', Item.diamond, 'O', Block.obsidian
                 });
         ModLoader.addRecipe(new ItemStack(DiamondStick, 8), new Object[]
                 {
                     "D", "D", 'D', Item.diamond
                 });
         ModLoader.addRecipe(new ItemStack(Block.netherBrick, 4), new Object[]
                 {
                     "BB", "BB", 'B', Netherstone
                 });
         ModLoader.addRecipe(new ItemStack(BlankAmulet, 1), new Object[]
                 {
                     "IGI", "GGG", "IGI", 'I', Item.ingotIron, 'G', Item.ingotGold
                 });
         ModLoader.addRecipe(new ItemStack(HellPickaxe, 1), new Object[]
                 {
                     "HHH", " S ", " S ", 'H', Hellstone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HellShovel, 1), new Object[]
                 {
                     " H ", " S ", " S ", 'H', Hellstone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HellAxe, 1), new Object[]
                 {
                     " HH", " SH", " S ", 'H', Hellstone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HellAxe, 1), new Object[]
                 {
                     "HH ", "HS ", " S ", 'H', Hellstone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HellHoe, 1), new Object[]
                 {
                     "HH ", " S ", " S ", 'H', Hellstone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HellHoe, 1), new Object[]
                 {
                     " HH", " S ", " S ", 'H', Hellstone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HellSword, 1), new Object[]
                 {
                     " H ", " H ", " S ", 'H', Hellstone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HolyPickaxe, 1), new Object[]
                 {
                     "HHH", " S ", " S ", 'H', Holystone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HolyShovel, 1), new Object[]
                 {
                     " H ", " S ", " S ", 'H', Holystone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HolyAxe, 1), new Object[]
                 {
                     " HH", " SH", " S ", 'H', Holystone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HolyAxe, 1), new Object[]
                 {
                     "HH ", "HS ", " S ", 'H', Holystone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HolyHoe, 1), new Object[]
                 {
                     "HH ", " S ", " S ", 'H', Holystone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HolyHoe, 1), new Object[]
                 {
                     " HH", " S ", " S ", 'H', Holystone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HolySword, 1), new Object[]
                 {
                     " H ", " H ", " S ", 'H', Holystone, 'S', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HolyBow, 1), new Object[]
                 {
                     "HDS", "D S", "HDS", 'H', Holystone, 'S', Item.silk, 'D', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(HellBow, 1), new Object[]
                 {
                     "HDS", "D S", "HDS", 'H', Hellstone, 'S', Item.silk, 'D', DiamondStick
                 });
         ModLoader.addRecipe(new ItemStack(TeleAmulet, 1), new Object[]
                 {
                     "DDD", "DAD", "DDD", 'D', Item.enderPearl, 'A', ChargedAmulet
                 });
         ModLoader.addRecipe(new ItemStack(ELHelm, 1), new Object[]
                 {
                     "LLL", "L L", 'L', EnchantLeather
                 });
         ModLoader.addRecipe(new ItemStack(ELBody, 1), new Object[]
                 {
                     "L L", "LLL", "LLL", 'L', EnchantLeather
                 });
         ModLoader.addRecipe(new ItemStack(ELLegs, 1), new Object[]
                 {
                     "LLL", "L L", "L L", 'L', EnchantLeather
                 });
         ModLoader.addRecipe(new ItemStack(ELBoots, 1), new Object[]
                 {
                     "L L", "L L", 'L', EnchantLeather
                 });
         ModLoader.addRecipe(new ItemStack(HolyHelm, 1), new Object[]
                 {
                     "LLL", "LDL", 'L', Holystone, 'D', ChargedDiamond
                 });
         ModLoader.addRecipe(new ItemStack(HolyBody, 1), new Object[]
                 {
                     "LDL", "LLL", "LLL", 'L', Holystone, 'D', ChargedDiamond
                 });
         ModLoader.addRecipe(new ItemStack(HolyLegs, 1), new Object[]
                 {
                     "LLL", "LDL", "L L", 'L', Holystone, 'D', ChargedDiamond
                 });
         ModLoader.addRecipe(new ItemStack(HolyBoots, 1), new Object[]
                 {
                     "L L", "LDL", 'L', Holystone, 'D', ChargedDiamond
                 }); 
         ModLoader.addRecipe(new ItemStack(HellHelm, 1), new Object[]
                 {
                     "LLL", "LDL", 'L', Hellstone, 'D', ChargedDiamond
                 });
         ModLoader.addRecipe(new ItemStack(HellBody, 1), new Object[]
                 {
                     "LDL", "LLL", "LLL", 'L', Hellstone, 'D', ChargedDiamond
                 });
         ModLoader.addRecipe(new ItemStack(HellLegs, 1), new Object[]
                 {
                     "LLL", "LDL", "L L", 'L', Hellstone, 'D', ChargedDiamond
                 });
         ModLoader.addRecipe(new ItemStack(HellBoots, 1), new Object[]
                 {
                     "L L", "LDL", 'L', Hellstone, 'D', ChargedDiamond
                 });   
         ModLoader.addRecipe(new ItemStack(BookofLore, 1), new Object[]
                 {
        	 		"LPP", "LPP", "LPP", 'L', EnchantLeather, 'P', EnchantPaper
                 });
         ModLoader.addRecipe(new ItemStack(StoneTablet, 1), new Object[]
                {
        	 		" S ", "SSS", "SSS", 'S', Block.stone
        	    });
         ModLoader.addRecipe(new ItemStack(StoneHammer, 1), new Object[]
                                                                       {
        	 		"SSS", "STS", " T ", 'S', Block.stone, 'T', Item.stick
                                                                       });
         ModLoader.addRecipe(new ItemStack(StoneChisel, 1), new Object[]
                                                                       {
        	 		"S  ", " T ", "  T", 'S', Block.stone, 'T', Item.stick
                                                                       });
    }

    void shapeless()
    {
    	ModLoader.addShapelessRecipe(new ItemStack(MagicPowder, 2), new Object[]
    	{
    		Item.redstone, Item.lightStoneDust
    	});
    	ModLoader.addShapelessRecipe(new ItemStack(MagicPowder, 8), new Object[]
    	{
    		Item.redstone, Item.lightStoneDust, Item.gunpowder
    	});  
    	ModLoader.addShapelessRecipe(new ItemStack(Item.melon, 9), new Object[]
    	{
    	    Block.melon
    	});
    	ModLoader.addShapelessRecipe(new ItemStack(ChargedAmulet, 1), new Object[]
    	{
    	    BlankAmulet, ChargedDiamond, ChargedDiamond
    	});
    	ModLoader.addShapelessRecipe(new ItemStack(StoneHammerChisel, 1), new Object[]
    	                                                                           {
    		StoneHammer, StoneChisel
    	                                                                           });
    	ModLoader.addShapelessRecipe(new ItemStack(AncientText, 1), new Object[]
    	                                                                           {
    		AncientText, new ItemStack(BookofLore, 1, -1)
    	                                                                           });
    	ModLoader.addShapelessRecipe(new ItemStack(StoneTablet, 1), new Object[]
    	                                                                       {
    		new ItemStack(AncientText, 1, -1), new ItemStack(StoneHammerChisel, 1, -1), StoneTablet
    	                                                                       });
    	
    	    	
    	//just a test recipe
    	ModLoader.addShapelessRecipe(new ItemStack(StoneHammerChisel, 64, 0), new Object[]
    	{
    		Block.dirt
    	});
    }
    
    void smelting()
    {
   	 	ModLoader.addSmelting(Block.netherrack.blockID, new ItemStack(Netherstone));
    }
    
    void repairrecipe()
    {
    	//Holystone Tools and weapons
    	ModLoader.addShapelessRecipe(new ItemStack(HolySword, 1), 
    			new Object[]
    			{
    				(new ItemStack(HolySword, 1, -1)), MagicPowder, MagicPowder
    			 });
    	ModLoader.addShapelessRecipe(new ItemStack(HolyBow, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HolyBow, 1, -1)), MagicPowder, MagicPowder
    	    	});
    	ModLoader.addShapelessRecipe(new ItemStack(HolyPickaxe, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HolyPickaxe, 1, -1)), MagicPowder, MagicPowder, MagicPowder
    	    	});
    	ModLoader.addShapelessRecipe(new ItemStack(HolyShovel, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HolyShovel, 1, -1)), MagicPowder
    	    	});
    	ModLoader.addShapelessRecipe(new ItemStack(HolyAxe, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HolyAxe, 1, -1)), MagicPowder, MagicPowder, MagicPowder
    	    	});
    	ModLoader.addShapelessRecipe(new ItemStack(HolyHoe, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HolyHoe, 1, -1)), MagicPowder, MagicPowder
    	    	});
    	
    	//Hellstone Tools and weapons
    	ModLoader.addShapelessRecipe(new ItemStack(HellSword, 1), 
    			new Object[]
    			{
    				(new ItemStack(HellSword, 1, -1)), MagicPowder, MagicPowder
    			 });
    	ModLoader.addShapelessRecipe(new ItemStack(HellBow, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HellBow, 1, -1)), MagicPowder, MagicPowder
    	    	});
    	ModLoader.addShapelessRecipe(new ItemStack(HellPickaxe, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HellPickaxe, 1, -1)), MagicPowder, MagicPowder, MagicPowder
    	    	});
    	ModLoader.addShapelessRecipe(new ItemStack(HellShovel, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HellShovel, 1, -1)), MagicPowder
    	    	});
    	ModLoader.addShapelessRecipe(new ItemStack(HellAxe, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HellAxe, 1, -1)), MagicPowder, MagicPowder, MagicPowder
    	    	});
    	ModLoader.addShapelessRecipe(new ItemStack(HellHoe, 1), 
    	    	new Object[]
    	    	{
    	    		(new ItemStack(HellHoe, 1, -1)), MagicPowder, MagicPowder
    	    	});
    	
    	//Holystone armor
    	ModLoader.addShapelessRecipe(new ItemStack(HolyHelm, 1), 
    			new Object[]
    			{
    				(new ItemStack(HolyHelm, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(HolyBody, 1), 
    			new Object[]
    			{
    				(new ItemStack(HolyBody, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(HolyLegs, 1), 
    			new Object[]
    			{
    				(new ItemStack(HolyLegs, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(HolyBoots, 1), 
    			new Object[]
    			{
    				(new ItemStack(HolyBoots, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	
    	//Hellstone armor
    	ModLoader.addShapelessRecipe(new ItemStack(HellHelm, 1), 
    			new Object[]
    			{
    				(new ItemStack(HellHelm, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(HellBody, 1), 
    			new Object[]
    			{
    				(new ItemStack(HellBody, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(HellLegs, 1), 
    			new Object[]
    			{
    				(new ItemStack(HellLegs, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(HellBoots, 1), 
    			new Object[]
    			{
    				(new ItemStack(HellBoots, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	
    	//EL armor
    	ModLoader.addShapelessRecipe(new ItemStack(ELHelm, 1), 
    			new Object[]
    			{
    				(new ItemStack(ELHelm, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(ELBody, 1), 
    			new Object[]
    			{
    				(new ItemStack(ELBody, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(ELLegs, 1), 
    			new Object[]
    			{
    				(new ItemStack(ELLegs, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	ModLoader.addShapelessRecipe(new ItemStack(ELBoots, 1), 
    			new Object[]
    			{
    				(new ItemStack(ELBoots, 1, -1)), MagicPowder, MagicPowder, MagicPowder, MagicPowder
    			});
    	
    	//misc repairs
    	ModLoader.addShapelessRecipe(new ItemStack(BookofLore, 1),
    			new Object[]
    			           {
    							(new ItemStack(BookofLore, 1, -1)), MagicPowder
    			           });
    }

    void sprites()
    {
        HellPickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/hellpickaxe.png");
        HellShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/hellshovel.png");
        HellAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/hellaxe.png");
        HellHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/hellhoe.png");
        HellSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/hellsword.png");
        HolyPickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/Holypickaxe.png");
        HolyShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/Holyshovel.png");
        HolyAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/Holyaxe.png");
        HolyHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/Holyhoe.png");
        HolySword.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/Holysword.png");
        HolyBow.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/holybow.png");
        HellBow.iconIndex = ModLoader.addOverride("/gui/items.png", "/karma/hellbow.png");
    }
    
    public static int stackInInventory(Item item, EntityPlayer player)
    {
        for (int i = 0; i < 29; i++)
        {
            if (player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() == item)
            {
                 return i;
            }
        }

        return 0;
    }
    
    public mod_KarmaCraft()
    {
        registers();
        names();
        crafting();
        smelting();
        shapeless();
        repairrecipe();
        sprites();
        guikarmahud = new GuiKarmaHUD();
        hellsword = (ItemHellSword)HellSword;
    }

    static
    {
        EL = EnumHelper.addArmorMaterial("EL", 10, new int[]
                {
                    1, 3, 2, 1
                }, 20);
        Holy = EnumHelper.addArmorMaterial("Holy", 25, new int[]{3, 8, 6, 3}, 20);
        Hell = EnumHelper.addArmorMaterial("Holy", 25, new int[]{3, 8, 6, 3}, 20);
        HOLY = EnumHelper.addToolMaterial("HOLY", 3, 780, 10F, 3, 20);
        HELL = EnumHelper.addToolMaterial("HELL", 3, 780, 10F, 3, 20);
        Holystone = (new BlockHolystone(125, ModLoader.addOverride("/terrain.png", "/karma/Holystone.png"))).setHardness(1.5F).setResistance(10F).setStepSound(Block.soundStoneFootstep).setLightValue(1.0F).setBlockName("holystone");
        Hellstone = (new BlockHellstone(126, ModLoader.addOverride("/terrain.png", "/karma/Hellstone.png"))).setHardness(1.5F).setResistance(10F).setStepSound(Block.soundStoneFootstep).setLightValue(-5F).setBlockName("hellstone");
        Netherstone = (new BlockNetherstone(127, ModLoader.addOverride("/terrain.png", "/karma/Netherstone.png"))).setHardness(1.5F).setResistance(10F).setStepSound(Block.soundStoneFootstep).setBlockName("netherstone");
        Enchanter = (new BlockEnchanter(128, false)).setHardness(2.0F).setResistance(50F).setStepSound(Block.soundMetalFootstep).setBlockName("enchanter");
        HellPickaxe = (new ItemHellstonePickaxe(7002, HELL)).setItemName("hellpickaxe");
        HellShovel = (new ItemHellShovel(7003, HELL)).setItemName("hellshovel");
        HellAxe = (new ItemHellAxe(7004, HELL)).setItemName("hellaxe");
        HellHoe = (new ItemHellHoe(7005, HELL)).setItemName("hellhoe");
        HellSword = (new ItemHellSword(7006, HELL)).setItemName("hellsword");
        HolyPickaxe = (new ItemHolyPickaxe(7008, HOLY)).setItemName("holypickaxe");
        HolyShovel = (new ItemHolyShovel(7009, HOLY)).setItemName("holyshovel");
        HolyAxe = (new ItemHolyAxe(7010, HOLY)).setItemName("holyaxe");
        HolyHoe = (new ItemHolyHoe(7011, HOLY)).setItemName("holyhoe");
        HolySword = (new ItemHolySword(7012, HOLY)).setItemName("holysword");
        ELHelm = (new ItemELHelm(7013, EL, ModLoader.addArmor("EnchantLeather"), 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/ELHelm.png")).setItemName("enchantedleatherhelm");
        ELBody = (new ItemELBody(7014, EL, ModLoader.addArmor("EnchantLeather"), 1)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/ELBody.png")).setItemName("enchantedleatherchest");
        ELLegs = (new ItemELLegs(7015, EL, ModLoader.addArmor("EnchantLeather"), 2)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/ELPants.png")).setItemName("enchantedleatherlegs");
        ELBoots = (new ItemELBoots(7016, EL, ModLoader.addArmor("EnchantLeather"), 3)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/ELBoots.png")).setItemName("enchantedleatherboots");
        HolyHelm = (new ItemHolyHelm(7023, Holy, ModLoader.addArmor("Holystone"), 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/HolyHelm.png")).setItemName("holyhelm");
        HolyBody = (new ItemHolyBody(7024, Holy, ModLoader.addArmor("Holystone"), 1)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/HolyBody.png")).setItemName("holychest");
        HolyLegs = (new ItemHolyLegs(7025, Holy, ModLoader.addArmor("Holystone"), 2)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/HolyPants.png")).setItemName("holylegs");
        HolyBoots = (new ItemHolyBoots(7026, Holy, ModLoader.addArmor("Holystone"), 3)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/HolyBoots.png")).setItemName("holyboots");
        HellHelm = (new ItemHellHelm(7027, Hell, ModLoader.addArmor("Hellstone"), 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/HellHelm.png")).setItemName("hellhelm");
        HellBody = (new ItemHellBody(7028, Hell, ModLoader.addArmor("Hellstone"), 1)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/HellBody.png")).setItemName("hellchest");
        HellLegs = (new ItemHellLegs(7029, Hell, ModLoader.addArmor("Hellstone"), 2)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/HellPants.png")).setItemName("helllegs");
        HellBoots = (new ItemHellBoots(7030, Hell, ModLoader.addArmor("Hellstone"), 3)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/karma/HellBoots.png")).setItemName("hellboots");        
    }

    @Override
	public void takenFromCrafting(EntityPlayer player, ItemStack itemstack, IInventory matrix)
	{
		if (itemstack != null && itemstack.getItem() == AncientText)
		{
			ItemAncientText.randomize(player, itemstack);
		}
		for(int i=0; i<matrix.getSizeInventory(); i++)
		{               
		         if(matrix.getStackInSlot(i) != null)
		         {
		         ItemStack itemnew = matrix.getStackInSlot(i);
		         if(itemnew != null && itemnew.getItem() == BookofLore)
		         {
		         ItemStack k = new ItemStack(BookofLore, 2);
		         k.damageItem(itemnew.getItemDamage() + 1, player);
		         matrix.setInventorySlotContents(i, k);
		         }
		         }      
		}
		if (itemstack != null && itemstack.getItem() == StoneTablet)
		{
			for(int i=0; i<matrix.getSizeInventory(); i++)
			{               
		         if(matrix.getStackInSlot(i) != null)
		         {
		        	 ItemStack itemnew = matrix.getStackInSlot(i);
		        	 if(itemnew != null && itemnew.getItem() == StoneHammerChisel)
		        	 {
		        		 ItemStack k = new ItemStack(StoneHammerChisel, 2);
		        		 k.damageItem(itemnew.getItemDamage() + 1, player);
		        		 matrix.setInventorySlotContents(i, k);
		        	 }
		        	 if(itemnew != null && itemnew.getItem() == AncientText)
		        	 {
		        		 int x = itemnew.getItemDamage();
		        		 itemstack.setItemDamage(x);
		        		 ItemStack k = new ItemStack(AncientText, 2, x);
		        		 matrix.setInventorySlotContents(i, k);
		        	 }
		         }      
			}
		}
		
	}
}
